﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HotelBookingSystem.DataBaseStuff
{
    class _Hotel : HotelFunctionalities
    {
        public string hotelName;
        public _Room[] oneBed;
        public _Room[] twoBed;
        public _Room[] app;

        public _Hotel()
        {
            hotelName = "";
            oneBed = new _Room[MyRandom.RanNum(30, 100)];
            twoBed = new _Room[MyRandom.RanNum(20, 50)];
            app = new _Room[MyRandom.RanNum(10, 20)];
            for (int k = 0; k < oneBed.Length; k++)
                oneBed[k] = new _Room();
            for (int k = 0; k < twoBed.Length; k++)
                twoBed[k] = new _Room();
            for (int k = 0; k < app.Length; k++)
                app[k] = new _Room();
        }

        public int[] getIndex(ResultRoom stuff, uint periodChoice)
        {
            //int index = 0;
            foreach (RoomInfo el in stuff.roomTree)
            {
                if (el.periodsTillNow == periodChoice)
                    return new int[2] { (int)el.roomNumber - 1, (int)el.currentPeriod - 1 };
                //index++;
            }
            return new int[2] { -1, -1 };
        }

        public void UpdateRooms(ResultRoom stuff, uint periodChoice, uint roomChoice)
        {
            int[] indeces = getIndex(stuff, periodChoice);
            switch (roomChoice)
            {
                case 1:
                    oneBed[indeces[0]].startDates.RemoveAt(indeces[1]);
                    break;
                case 2:
                    twoBed[indeces[0]].startDates.RemoveAt(indeces[1]);
                    break;
                case 3:
                    app[indeces[0]].startDates.RemoveAt(indeces[1]);
                    break;
            }
        }
    }
}